package org.im.service.user.impl;

import org.im.service.user.bean.UserInfo;

import com.wj.jssdb.pool.JssdbClient;

public class JssdbService {
    private String userNameJssdbKey(String userName) {
        return "userinfo_" + userName;
    }
    private String sessionJssdbKey(String userName) {
        return "session_" + userName;
    }
    
    public void setUserInfoByUserName(String userName, UserInfo userInfo) {
        jssdbClient.setPojo(userNameJssdbKey(userName), userInfo);
    }
    public UserInfo getUserInfoByUserName(String userName) {
        return jssdbClient.getPojo(userNameJssdbKey(userName));
    }

    public void loginSessionId(String userName, String sessionId) {
        jssdbClient.setExp(sessionJssdbKey(userName), sessionId, 600);
    }
    
    public String getSessionId(String userName) {
        return jssdbClient.get(sessionJssdbKey(userName));
    }
    
//    @Resource(name = "jssdbClient")
    protected JssdbClient jssdbClient;
}
